home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / SHELLS / SZ2 / ADEMO6.INC < prev    next >
Text File  |  1992-08-31  |  5KB  |  112 lines

  1.    {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  2.  
  3.    EditorDialog
  4.  
  5.    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
  6.    {===================================================================
  7.  
  8.    SEARCH - created with DLGDSN
  9.  
  10.    ===================================================================}
  11. function CreateFindDialog : PDialog ;
  12. {$IFDEF code} {$I find.src } {$ENDIF}
  13. begin
  14. {$IFDEF code}
  15.    CreateFindDialog          := MakeDialog ;
  16. {$ELSE}
  17.    CreateFindDialog          := PDIALOG ( RezFile^.Get ( 'DIALOG_FIND' ) ) ;
  18. {$ENDIF}
  19. end ;
  20.    {===================================================================
  21.  
  22.    REPLACE - created with DLGDSN
  23.  
  24.    ===================================================================}
  25. function CreateReplaceDialog : PDialog ;
  26. {$IFDEF code} {$I replace.src } {$ENDIF}
  27. begin
  28. {$IFDEF code}
  29.    CreateReplaceDialog       := MakeDialog ;
  30. {$ELSE}
  31.    CreateReplaceDialog       := PDIALOG ( RezFile^.Get ( 'DIALOG_REPLACE' ) ) ;
  32. {$ENDIF}
  33. end ;
  34.    {===================================================================
  35.  
  36.    Add SEARCH & REPLACE
  37.  
  38.    ===================================================================}
  39.    {===================================================================
  40.  
  41.    EXECUTE
  42.  
  43.    ===================================================================}
  44. function EditorDialog ( Dialog : Integer ;
  45.                         Info : Pointer ) : word ;
  46. var
  47.    R                         : TRect ;
  48.    T                         : TPoint ;
  49. begin
  50.    case Dialog of
  51.    edOutOfMemory :
  52.       EditorDialog           := MessageBox ( ^C'Not enough memory for this operation.' ,
  53.                                              NIL ,
  54.                                              mfError + mfOkButton ) ;
  55.    edReadError :
  56.       EditorDialog           := MessageBox ( ^C'Error reading file %s.' ,
  57.                                              @Info ,
  58.                                              mfError + mfOkButton ) ;
  59.    edWriteError :
  60.       EditorDialog           := MessageBox ( ^C'Error writing file %s.' ,
  61.                                              @Info ,
  62.                                              mfError + mfOkButton ) ;
  63.    edCreateError :
  64.       EditorDialog           := MessageBox ( ^C'Error creating file %s.' ,
  65.                                              @Info ,
  66.                                              mfError + mfOkButton ) ;
  67.    edSaveModify :
  68.       EditorDialog           := MessageBox ( ^C'%s has been modified. Save?' ,
  69.                                              @Info ,
  70.                                              mfInformation + mfYesNoCancel ) ;
  71.    edSaveUntitled :
  72.       EditorDialog           := MessageBox ( ^C'Save untitled file?' ,
  73.                                              NIL ,
  74.                                              mfInformation + mfYesNoCancel ) ;
  75.    edSaveAs :
  76.       EditorDialog           := ExecDialog ( New ( PFileDialog , Init ( '*.*' ,
  77.                                              'Save file as' ,
  78.                                              '~N~ame' ,
  79.                                              fdOkButton ,
  80.                                              101 ) ) , Info ) ;
  81.    edFind :
  82.       EditorDialog           := ExecDialog ( CreateFindDialog , Info ) ;
  83.    edSearchFailed:
  84.       EditorDialog           := MessageBox ( ^C'Search string not found.' ,
  85.                                              NIL ,
  86.                                              mfError + mfOkButton ) ;
  87.    edReplace :
  88.       EditorDialog           := ExecDialog ( CreateReplaceDialog , Info ) ;
  89.    edReplacePrompt :
  90.       begin
  91.    {- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  92.    Avoid placing the dialog on the same line as the cursor
  93.    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
  94.          R.Assign ( 0 , 1 , 40 , 8 ) ;
  95.          R.Move ( ( Desktop^.Size.X - R.B.X ) div 2 , 0 ) ;
  96.          Desktop^.MakeGlobal ( R.B , T ) ;
  97.          Inc ( T.Y ) ;
  98.          if TPoint(Info).Y <= T.Y then
  99.             R.Move ( 0 , Desktop^.Size.Y - R.B.Y - 2 ) ;
  100.          EditorDialog        := MessageBoxRect ( R ,
  101.                                                  ^C'Replace this occurence?' ,
  102.                                                  NIL ,
  103.                                                  mfYesNoCancel
  104.                                                  + mfInformation ) ;
  105.       end ;
  106.    else
  107.       MessageBox ( ^C'Unknown DIALOG requested!' ,
  108.                    NIL ,
  109.                    mfError + mfOkButton ) ;
  110.    end ;
  111. end ;
  112.